let utils = {
    //获取cookie、
    getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg))
            return (arr[2]);
        else
            return null;
    },
    //设置cookie,增加到vue实例方便全局调用
    setCookie(c_name, value, expiredays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + expiredays);
        document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
    },
    //删除cookie
    delCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = getCookie(name);
        if (cval != null)
            document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
    },
    //获取url中的参数
    getQueryStringByName(name) {
        var result = location.href.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
        if (result == null || result.length < 1) {
            return "";
        }
        return result[1];
    },
    //验证数据是否为空或空字符
    isNullOrEmpty(str) {
        return str == null || str.toString().trim() == "";
    },
    //验证数据是否为undefined
    isUndefined(str) {
        return typeof (str) == "undefined";
    },
    //验证数据是否为空或空字符
    isEmptyGuid(str) {
        return str == "00000000-0000-0000-0000-000000000000";
    },
    //克隆对象
    clone(origin) {
        // return Object.assign({}, origin);
        // 深拷贝
        return JSON.parse(JSON.stringify(origin));
    }
};

export {
    utils
}  